package org.example.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.example.entity.Emp;
import org.example.mapper.EmpMapper;
import org.example.query.PageParams;
import org.example.result.PageList;
import org.example.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpMapper empMapper;


    @Override
    public List<Emp> queryAll() {
        return null;
    }

    @Override
    public PageList<Emp> queryPage(PageParams<Emp> pageParams) {

        //分页  pageHelper
        Page<Emp> page = PageHelper.startPage(pageParams.getPageNum(), pageParams.getPageSize());

        //查询数据
        List<Emp> list = empMapper.queryAll(pageParams);

        return new PageList<>(page.getTotal(),page.getResult());
    }
}
